/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Locale;

/**
 * <p>Project: javase - Format4
 * <p>Powered by webrx On 2021-11-23 10:26:51
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Format4 {
    public static void main(String[] args) {

        //10.00 020 ff 09
        System.out.printf("%.2f %03d %02x %02x%n", 10f, 20, 255, 9);

        //124,234,212.57
        System.out.printf("%,.2f%n", 124234212.567);

        NumberFormat nf = NumberFormat.getPercentInstance();
        //20%
        System.out.println(nf.format(.2));

        nf = NumberFormat.getCurrencyInstance(Locale.CHINA);
        System.out.println(nf.format(100.56));

        nf = NumberFormat.getNumberInstance();
        nf.setMaximumFractionDigits(2);
        System.out.println(nf.format(1242342.2341243));

        DecimalFormat df = new DecimalFormat("#,##0.##");
        System.out.println(df.format(1234246.55555));

    }
}
